<%@page import="java.util.ArrayList"%>
<%@page import="cn.sendto.model.ResidentInfoModel"%>
<%@page import="cn.sendto.model.UserInfoModel"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" errorPage="err.jsp"%>
<jsp:include page="lock.jsp"></jsp:include>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改个人信息</title>
<style>
.txt20 {
	font-size: 20px;
}

.td {
	font-size: 18px;
	height: 50px;
	text-align: right;
}
</style>
</head>
<%
	request.setCharacterEncoding("UTF-8");
%>
<body>
	<div class="txt20">当前位置-->修改个人信息</div>
	<%
		//修改后信息
		if (request.getAttribute("alter") != null) {
			out.print(request.getAttribute("alter"));
		}

		request.setCharacterEncoding("UTF-8");
		//判断错误信息
		ArrayList<Integer> errlist = new ArrayList<Integer>();
		if (request.getAttribute("errinfo") != null) {
			errlist = (ArrayList<Integer>) request.getAttribute("errinfo");
		}
		//业主
		if (session.getAttribute("ranks") != null) {
			if (session.getAttribute("ranks").equals("1") || session.getAttribute("loginResident") != null) {
				ResidentInfoModel rim = (ResidentInfoModel) session.getAttribute("loginResident");
	%>


	<form action="doalterinfo.jsp?rank=1" method="post">
		<table width="95%" cellspacing="1" cellpadding="0" align="center"
			style="background-color: azure">
			<tr>
				<td colspan="2" height="30px"></td>
			</tr>
			<tr>
				<td class="td">用户名：</td>
				<td><input type="text" name="username"
					value="<%=rim.getUserName()%>" readonly="readonly"></td>
			</tr>
			<tr>
				<td class="td">姓&nbsp;名：</td>
				<td><input type="text" name="name" value="<%=rim.getName()%>">
					<%
					//姓名是否输入
						for (int i = 0; i < errlist.size(); i++) {
									if (errlist.get(i) == 1) {
										out.println("<span class=\"star\">*请输入姓名。</span>");
										break;
									}
								}
					%></td>
			</tr>
			
			<tr>
				<td class="td">电&nbsp;话：</td>
				<td><input type="text" name="tellphone"
					value="<%=rim.getTellphone()%>"> <%
 	for (int i = 0; i < errlist.size(); i++) {
 				if (errlist.get(i) == 4) {
 					out.println("<span class=\"star\">*请输入电话。</span>");
 					break;
 				}
 			}
 %></td>
			</tr>
			
			<tr>
				<td></td>
				<td height="50px"><input type="submit" name="submit" value="提交"
					style="width: 100px; height: 25px"></td>
			</tr>
		</table>
	</form>

	<%
	//管理员
		} else if (session.getAttribute("ranks") != null || session.getAttribute("ranks").equals("2")
					|| session.getAttribute("loginUser") != null) {
				UserInfoModel uim = (UserInfoModel) session.getAttribute("loginUser");
	%>
	<form action="doalterinfo.jsp?rank=2" method="post">
		<table width="95%" cellspacing="1" cellpadding="0" align="center"
			style="background-color: azure">
			<tr>
				<td colspan="2" height="30px"></td>
			</tr>
			<tr>
				<td class="td">用户名：</td>
				<td><input type="text" name="username"
					value="<%=uim.getUserName()%>" readonly="readonly"></td>
			</tr>
			<tr>
				<td class="td">姓&nbsp;名：</td>
				<td><input type="text" name="name" value="<%=uim.getName()%>">
					<%
						for (int i = 0; i < errlist.size(); i++) {
									if (errlist.get(i) == 1) {
										out.println("<span class=\"star\">*请输入姓名。</span>");
										break;
									}
								}
					%></td>
			</tr>
			<tr>
				<td class="td">电&nbsp;话：</td>
				<td><input type="text" name="usertel"
					value="<%=uim.getUsertel()%>"> <%
 	for (int i = 0; i < errlist.size(); i++) {
 				if (errlist.get(i) == 1) {
 					out.println("<span class=\"star\">*请输入电话号。</span>");
 					break;
 				}
 			}
 %></td>
			</tr>
			<tr>
				<td></td>
				<td height="50px"><input type="submit" name="submit" value="提交"
					style="width: 100px; height: 25px"></td>
			</tr>
		</table>
	</form>
	<%
		} else {
				out.print("请联系管理员");
			}
		}
	%>
</body>
</html>